import { proRequest } from "@/utils/http";
import { attrItem, attrListType, categoryList } from './model/attrTypes'

// 获取一级分类
export const reqCategory1List = () => {
  return proRequest.get<any, categoryList>('/admin/product/getCategory1')
}
// 获取二级分类
export const reqCategory2List = (category1Id: number) => {
  return proRequest.get<any, categoryList>(`/admin/product/getCategory2/${category1Id}`)
}
// 获取三级分类
export const reqCategory3List = (category2Id: number) => {
  return proRequest.get<any, categoryList>(`/admin/product/getCategory3/${category2Id}`)
}

// 获取平台属性列表
export const reqAttrList = (category1Id:number,category2Id:number,category3Id:number) => {
  return proRequest.get<any,attrListType>(`/admin/product/attrInfoList/${category1Id}/${category2Id}/${category3Id}`)
}

// 添加或新增平台属性
export const reqAddOrUpdateAttrValue = (attr:attrItem) => {
  return proRequest.post<any,null>('/admin/product/saveAttrInfo',attr)
}

// 删除平台属性
export const reqDelAttr = (attrId:number) => {
  return proRequest.delete<any,null>(`/admin/product/deleteAttr/${attrId}`)
}